/*
 * @Author: zhouwei wei.zhou@flip.fun
 * @Date: 2024-04-09 14:52:13
 * @LastEditors: zhouwei wei.zhou@flip.fun
 * @LastEditTime: 2024-04-09 15:27:15
 * @FilePath: /50/手撕系列/shuffle.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
function shuffle(arr) {
	let length = arr.length
	while (length > 1) {
		const index = Math.floor(Math.random() * length--)
		;[arr[length], arr[index]] = [arr[index], arr[length]]
	}
	return arr
}
console.log(shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));